﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.VisualStudio.TestTools.UITesting.WinControls;
using Microsoft.VisualStudio.TestTools.UITesting;

namespace MSN
{
    public class LoginWindow : WinMSNBase
    {
        private WinEdit emailAddressEdit;
        private WinEdit passwordEdit;
        private WinControl statusButton;
        // private WinComboBox statusComboBox;
        private WinCheckBox rememberIDAndPwdCheckBox;
        private WinCheckBox autoSignInCheckBox;
        private WinButton signInButton;
        private WinButton cancelButton;

        public LoginWindow() : base() { }
        /*public TestLoginWindow()
        {
            this.SearchProperties[WinWindow.PropertyNames.Name] = TestConstVariable.MSN;
            this.SearchProperties[WinWindow.PropertyNames.ClassName] = "SharedSignDialogClass";
            this.WindowTitles.Add(TestConstVariable.MSN);   
        }*/

        public WinEdit EmailAddressEdit
        {
            get
            {
                if (this.emailAddressEdit == null)
                {
                    this.emailAddressEdit = new WinEdit(this);
                    this.emailAddressEdit.SearchProperties[WinEdit.PropertyNames.Name] = "Email address:";
                    this.emailAddressEdit.WindowTitles.Add(ConstVariable.MSN);
                }
                return this.emailAddressEdit;
            }
        }

        public WinEdit PasswordEdit
        {
            get
            {
                if (this.passwordEdit == null)
                {
                    this.passwordEdit = new WinEdit(this);
                    this.passwordEdit.SearchProperties[WinEdit.PropertyNames.Name] = "Password:";
                    this.passwordEdit.WindowTitles.Add(ConstVariable.MSN);
                }
                return this.passwordEdit;
            }
        }

        public WinControl StatusButton
        {
            get
            {
                if (this.statusButton == null)
                {
                    this.statusButton = new WinControl(this);
                    this.statusButton.SearchProperties[UITestControl.PropertyNames.Name] = "Status:";
                    this.statusButton.SearchProperties[UITestControl.PropertyNames.ControlType] = "MenuButton";
                    this.statusButton.WindowTitles.Add(ConstVariable.MSN);
                }
                return this.statusButton;
            }
        }

        public WinCheckBox RememberIDAndPwdCheckBox
        {
            get
            {
                if (this.rememberIDAndPwdCheckBox == null)
                {
                    this.rememberIDAndPwdCheckBox = new WinCheckBox(this);
                    this.rememberIDAndPwdCheckBox.SearchProperties[WinCheckBox.PropertyNames.Name] = "Remember my ID and password";
                    this.rememberIDAndPwdCheckBox.WindowTitles.Add(ConstVariable.MSN);
                }
                return this.rememberIDAndPwdCheckBox;
            }
        }

        public WinCheckBox AutoSingnInCheckBox 
        {
            get
            {
                if (this.autoSignInCheckBox == null)
                {
                    this.autoSignInCheckBox = new WinCheckBox(this);
                    this.autoSignInCheckBox.SearchProperties[WinCheckBox.PropertyNames.Name] = "Sign me in automatically";
                    this.autoSignInCheckBox.WindowTitles.Add(ConstVariable.MSN);
                }
                return this.autoSignInCheckBox;
            }
        }

        public WinButton SignInButton
        {
            get 
            {
                if (this.signInButton == null)
                {
                    this.signInButton = new WinButton(this);
                    this.signInButton.SearchProperties[WinButton.PropertyNames.Name] = "Sign in";
                    this.signInButton.WindowTitles.Add(ConstVariable.MSN);
                }
                return this.signInButton;
            }
        }

        public WinButton CancelButton
        {
            get 
            {
                if (this.cancelButton == null)
                {
                    this.cancelButton = new WinButton(this);
                    this.cancelButton.SearchProperties[WinButton.PropertyNames.Name] = "Cancel";
                    // this.cancelButton.SearchProperties[WinButton.PropertyNames.AccessKey] = "Alt + n";
                    this.cancelButton.WindowTitles.Add(ConstVariable.MSN);
                }
                return this.cancelButton;
            }
        }
    }    
}
